package cn.ssm.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.ssm.pojo.Users;
import cn.ssm.service.UsersService;


@Controller
@RequestMapping("/usersController")
public class UsersController {
	
	@Autowired
	@Qualifier("usersService")
	private UsersService usersService;
	
	@RequestMapping("/login")
	public String login(Users users,ModelMap model){
		String url = null;
		List<Users> userName =usersService.selectusersAll();
		if(userName!=null){
			model.put("userName",userName.get(0).getLoginName() );
			url="redirect:/gradeController/selectGrade";
		}                           
		else {
			model.put("error", "error");
			url = "login";
		}	
		return url;	
				
	}

}
